//
//  FirstCell.m
//  B段项目
//
//  Created by dllo on 15/9/24.
//  Copyright (c) 2015年 昶博. All rights reserved.
//

#import "FirstCell.h"
#import "PrefixHeader.pch"
#import "FirstModel.h"
#import <UIImageView+WebCache.h>

@implementation FirstCell


//初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //新闻图片初始化
        self.newsImage = [[UIImageView alloc] init];
        //新闻标题初始化
        self.newsLabel = [[UILabel alloc] init];
        self.newsLabel.font = [UIFont systemFontOfSize:15];
        self.newsLabel.numberOfLines = 0;
        //新闻种类初始化
        self.typyLabel = [[UILabel alloc] init];
        self.typyLabel.font = [UIFont systemFontOfSize:11];
        //评论数量初始化
        self.commentLabel = [[UILabel alloc] init];
        self.commentLabel.font = [UIFont systemFontOfSize:11];
        //评论图片初始化
        self.commentImage = [[UIImageView alloc] init];
        
        [self.contentView addSubview:self.newsImage];
        [self.contentView addSubview:self.newsLabel];
        [self.contentView addSubview:self.typyLabel];
        [self.contentView addSubview:self.commentImage];
        [self.contentView addSubview:self.commentLabel];
        
    }
    return self;
}

//布局子视图
- (void)layoutSubviews
{
    [super layoutSubviews];
    //新闻图片
    self.newsImage.frame = CGRectMake(ScreenWidth * 5 / 375, ScreenHeight * 5 / 667, ScreenWidth * 110 / 375, ScreenHeight * 90 / 667);
    //新闻标题
    self.newsLabel.frame = CGRectMake(ScreenWidth * 125 / 375, ScreenHeight * 5 / 667, ScreenWidth * 240 / 375, ScreenHeight * 45 / 667);
    //新闻种类
    self.typyLabel.frame = CGRectMake(ScreenWidth * 125 / 375, ScreenHeight * 70 / 667, ScreenWidth * 70 / 375, ScreenHeight * 20 / 667);
    //评论图片
    self.commentImage.frame = CGRectMake(ScreenWidth * 280 / 375, ScreenHeight * 72 / 667, ScreenWidth * 15 / 375, ScreenHeight * 15 / 667);
    //评论数量
    self.commentLabel.frame = CGRectMake(ScreenWidth * 300 / 375, ScreenHeight * 68 / 667, ScreenWidth * 50 / 375, ScreenHeight * 20 / 667);
    
}

//model传值
- (void)setFirstModel:(FirstModel *)firstModel
{
    self.newsLabel.text = firstModel.newsTitle;
    self.typyLabel.text = firstModel.newsCategory;
    self.commentLabel.text = [NSString stringWithFormat:@"%@",firstModel.commentCount];
    self.commentImage.image = [UIImage imageNamed:@"pinglun.png"];
    [self.newsImage sd_setImageWithURL:[NSURL URLWithString:firstModel.newsImage] placeholderImage:[UIImage imageNamed:@"zhanwei.png"]];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
